-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[step4] 로또(수동) #1086
base: pkch93
Are you sure you want to change the base?
[step4] 로또(수동) #1086
Conversation
- Exception 문구에 정보 추가
- PositiveNumber 정의
- 입력 식 파싱 로직 간소화
- Reward의 당첨 정책 함수로 반영
- in operator로 contains 대체
THIRD(1_500_000, 5, { matchingNumberCount, _ -> matchingNumberCount == 5 }), | ||
FOURTH(50_000, 4, { matchingNumberCount, _ -> matchingNumberCount == 4 }), | ||
FIFTH(5_000, 3, { matchingNumberCount, _ -> matchingNumberCount == 3 }), | ||
NONE(0, 0, { matchingNumberCount, _ -> matchingNumberCount < 3 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 needMatchBonus
부분이 꺼림찍하긴 했는데 이 구현이 좀더 나은거 같네요 :)
인터페이스 정의할 거 없이 함수로 정의해도 될거 같아서 위와 같이 반영했습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
fun match(lotto: Lotto): Reward { | ||
val matchingNumberCount = this.lotto | ||
.numbers | ||
.count { lotto.numbers.contains(it) } | ||
.count { it in lotto.numbers } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in
으로 표현하는게 더 읽기 편해서 위와 같이 수정했어요
제가 저번 리뷰에서 참고차 알려드린다는게 누락한 부분이 있는데요 BoughtLotto에서 EnumMap으로 init하는 부분을 kotlin에서 제공하는 함수를 이용하면 여러가지 방법으로 표현해볼 수 있습니다. ex. return Reward.entries
.associateWith { 0 }
.toMap(EnumMap(Reward::class.java)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
조금 개선해보면 좋을 부분에 리뷰를 남겨두었으니 확인해주세요~
THIRD(1_500_000, 5, { matchingNumberCount, _ -> matchingNumberCount == 5 }), | ||
FOURTH(50_000, 4, { matchingNumberCount, _ -> matchingNumberCount == 4 }), | ||
FIFTH(5_000, 3, { matchingNumberCount, _ -> matchingNumberCount == 3 }), | ||
NONE(0, 0, { matchingNumberCount, _ -> matchingNumberCount < 3 }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
val manualLottos = inputManualLottoNumbers(lottoCost) | ||
|
||
val autoLottoAmount = lottoCost.autoLottoAmount | ||
val autoLottos = (1..autoLottoAmount).map { Lotto.auto() } | ||
|
||
val generatedLottos = manualLottos + autoLottos | ||
printBoughtLottos(lottoCost, generatedLottos) | ||
return generatedLottos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이러한 부분은 view에서 구현하기 적합해 보이지 않는것 같습니다.
view의 종류가 늘어나면 종류가 늘어남과 동시에 위와 같이 생성하는 로직 또한 계속해서 늘어나지 않을까요?
로또 애플리케이션의 중요한 정책으로 보이는데 domain 영역에서 구현해보는게 어떨까요?
@@ -1,6 +1,7 @@ | |||
package lotto | |||
|
|||
class Lotto( | |||
class Lotto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 클래스에서 상수로 표현하기 적합한 값들이 몇몇 보이는 것 같습니다.
로또 미션 4단계 로또(수동) 구현해서 MR 올립니다.
이전에 남겨주신 부분 반영한건 코멘트로 남길께요 :)